/**
 * Strike.java
 * 
 * This class is a concrete handler in the Chain of Responsibility pattern. It
 * represents the first ball in a frame when it knocks down all the pins for
 * that frame. The score returned by getCalculatedScore is the number of pins
 * knocked down for this ball plus the number of pins knocked by the next ball
 * if it was thrown and the pins knocked down by the ball after that if that
 * ball was thrown too.
 * 
 * @author Robert Yates
 */
public class Strike extends ScoreHandler {

	/**
	 * Construct a strike with a given score.
	 * 
	 * @param score 	The original score of the ball.
	 */
	public Strike(int score) {
		// Strike score should always be 10.
		setOriginalScore(score);
	}

	/**
	 * Returns the most accurate calculation of the score.
	 * 
	 * @return 		The original score plus any subsequent scores if they are 
	 * 				used to calculate this total score.
	 */
	@Override
	public int getCalculatedScore() {
		// A strike's calculated score is the original score plus the next
		// handler's original score if the next handler exists plus the original
		// score of the handler after that if that also exists.
		int cumulativeScore = originalScore;
		if (nextHandler != null) {
			cumulativeScore += nextHandler.getOriginalScore();
			if (nextHandler.nextHandler != null) {
				cumulativeScore += nextHandler.nextHandler.getOriginalScore();
			}
		}
		return cumulativeScore;
	}
}
